/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.sanerzone.smscenter.modules.sms.service;

import java.util.List;

import com.sanerzone.smscenter.biz.iface.SmsSubmitTemplateInterface;
import com.sanerzone.smscenter.modules.sms.dao.SmsSubmitTemplateDao;
import com.sanerzone.smscenter.modules.sms.entity.SmsSubmitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sanerzone.jeebase.common.persistence.Page;
import com.sanerzone.jeebase.common.service.CrudService;

/**
 * 单表生成Service
 * @author ThinkGem
 * @version 2017-12-25
 */
@Service
@Transactional(readOnly = true)
public class SmsSubmitTemplateService extends CrudService<SmsSubmitTemplateDao, SmsSubmitTemplate> {

	@Autowired
	SmsSubmitTemplateInterface smsSubmitTemplateInterface;

	public SmsSubmitTemplate get(String id) {
		return super.get(id);
	}
	
	public List<SmsSubmitTemplate> findList(SmsSubmitTemplate smsSubmitTemplate) {
		return super.findList(smsSubmitTemplate);
	}
	
	public Page<SmsSubmitTemplate> findPage(Page<SmsSubmitTemplate> page, SmsSubmitTemplate smsSubmitTemplate) {
		return super.findPage(page, smsSubmitTemplate);
	}
	
	@Transactional(readOnly = false)
	public void save(SmsSubmitTemplate smsSubmitTemplate) {
		super.save(smsSubmitTemplate);
		dobboSubmitTemplate(1,smsSubmitTemplate.getId());
	}
	
	@Transactional(readOnly = false)
	public void delete(SmsSubmitTemplate smsSubmitTemplate) {
		super.delete(smsSubmitTemplate);
		dobboSubmitTemplate(2,smsSubmitTemplate.getId());
	}

	private void dobboSubmitTemplate(int type, String id){
		com.sanerzone.smscenter.biz.entity.SmsSubmitTemplate entity = dao.findBizEntity(id);
		smsSubmitTemplateInterface.configSubmitTemplate(type,entity.getId(), entity);
	}
}